﻿using System;
using System.Linq;

namespace ScratchPad
{
    
    public class Program
    {
        // Wrapper function
        private static double Pow(double a, double b)
        {
            return Math.Pow(a, b);
        }

        static bool foo()
        {
            return true;
        }

        static bool bar()
        {
            return true;
        }

        public class Foo
        {
            public static Foo operator ++(Foo f)
            {
                return f;
            }
        }

        class Bar
        {
            
        }

        private static void Main(string[] args)
        {
            unchecked
            {
                uint x = (uint) -1;
                x = x >> 1;
            }
            int q = sizeof(int);
           // bool x = foo() | bar();
            var f = new Foo();
            unchecked
            {
                int i = Int32.MaxValue + 1;
            }

            int[] array = {1, 2, 3, 6, 7, 8};
            // Query expression.
            var elements = from element in array
                           orderby element descending
                           where element > 2
                           select Pow(element,2);
            elements = elements.ToList();
            // Enumerate.
            foreach (var element in elements)
            {
                Console.Write(element);
                Console.Write(' ');
            }
            Console.WriteLine();

            // Fraction[] list =
            //     {
            //         new Fraction {Numerator = 1, Denominator = 2},
            //         new Fraction {Numerator = 2, Denominator = 3},
            //         new Fraction {Numerator = 2, Denominator = 2}
            //     };
            // // LINQ
            // var 

            // // LINQ extension methods
            // list.Where(f => f.Denominator == 2)
            //     .ToList()
            //     .ForEach(Console.WriteLine);

            //// Console.WriteLine(f.Numerator)};
            Console.ReadKey();
        }
    }

    class Fraction
    {
        // autoproperty
        public int Numerator { get; set; }

        public int Denominator
        {
            get { return d; }
            set
            {
                if (value == 0)
                    throw new DivideByZeroException();
                d = value;
            }
        }
        private int d;
    }

    //internal struct Fraction
    //{
    //    public String Name { get; set; }

    //    public int Numerator;

    //    public int Denominator
    //    {
    //        get { return d; }
    //        set
    //        {
    //            if (value == 0)
    //                throw new ArgumentOutOfRangeException();
    //            d = value; 
    //        }
    //    }
    //    private int d;
    //}
}
